package com.usvisatrack.core.factories;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.type.LongType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.usvisatrack.core.common.Factory;
import com.usvisatrack.core.dao.model.ConfApp;
import com.usvisatrack.core.dao.model.SocialMediaLog;
import com.usvisatrack.core.dao.model.Visa;
import com.usvisatrack.core.dao.model.VisaClass;

public class ConfFactory {
	private static final int LISTING_PAGE_SIZE = 20;
	public static final int DEFAULT_AUTH_EXPIRATION = 10;

	private static Logger logger = LoggerFactory.getLogger(ConfFactory.class);

	/**
	 * Get ConfApp by Name
	 * 
	 * @param id
	 * @return
	 */
	public static ConfApp get(String confName) {
		logger.debug("Get ConfApp by Name - [{}]", confName);

		Factory.beginTransaction();
		try {
			Criteria criteria = Factory.createCriteria(ConfApp.class);
			criteria.add(Restrictions.eq("name", confName));
			return (ConfApp) criteria.uniqueResult();
		} catch (Exception ex) {
			logger.error("search item by item name error", ex);
		} finally {
			Factory.commitTransaction();
		}
		return null;
	}

	public static void save(ConfApp confApp) {
		try {
			Factory.beginTransaction();
			Factory.saveOrUpdate(confApp);
			Factory.commitTransaction();
		} catch (Exception ex) {
			logger.error("Save ConfApp OBJ ERROR", ex);
			Factory.rollbackTransaction();
		}
	}

}